package com.zhku.laosiji.service.Impl;

import com.zhku.laosiji.dao.MessageMapper;
import com.zhku.laosiji.pojo.Message;
import com.zhku.laosiji.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LINWENHAO on 2018/9/11.
 */
@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public List<Message> findAll(String keyword) {
        return messageMapper.selectAll(keyword);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int delete(Integer id) {
        return messageMapper.deleteByPrimaryKey(id);
    }

    /**
     * 查找
     * @param id
     * @return
     */
    @Override
    public Message findByid(Integer id) {
        return messageMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(Message message) {
        return messageMapper.updateByPrimaryKey(message);
    }

    @Override
    public List<Message> selectAllByUser(Integer userId) {
        return messageMapper.selectAllByUser(userId);
    }

    @Override
    public int insert(Message record) {
        return messageMapper.insert(record);
    }
}
